/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2012
 */

package com.hibernate.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.validation.constraints.NotNull;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.javacommon.base.BaseEntity;

/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


@Entity
@Table(name = "MEDIA_RELATIONSHIP")
public class MediaRelationship extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "MediaRelationship";
	public static final String ALIAS_ID = "关系标识";
	public static final String ALIAS_USER_ID = "用户标识";
	public static final String ALIAS_CHANNEL_ID = "渠道标识";
	public static final String ALIAS_WEBSITE_ID = "网站标识";
	public static final String ALIAS_LABEL_ID = "栏目标识";
	public static final String ALIAS_ADSITE_ID = "广告位标识";
	public static final String ALIAS_LEVEL = "级别 1渠道 2网站 3栏目 4广告位";
	
	
	//date formats
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * 关系标识       db_column: ID 
     */ 	
	
	private java.lang.Long id;
    /**
     * 用户标识       db_column: USER_ID 
     */ 	
	@NotNull 
	private java.lang.Long userId;
    /**
     * 渠道标识       db_column: CHANNEL_ID 
     */ 	
	
	private java.lang.Long channelId;
    /**
     * 网站标识       db_column: WEBSITE_ID 
     */ 	
	
	private java.lang.Long websiteId;
    /**
     * 栏目标识       db_column: LABEL_ID 
     */ 	
	
	private java.lang.Long labelId;
    /**
     * 广告位标识       db_column: ADSITE_ID 
     */ 	
	
	private java.lang.Long adsiteId;
    /**
     * 级别 1渠道 2网站 3栏目 4广告位       db_column: LEVEL 
     */ 	
	@NotNull 
	private java.lang.Integer level;

	//columns END

	public MediaRelationship(Long userId, Long channelId, Long websiteId,
			Long labelId, Long adsiteId, Integer level) {
		super();
		this.userId = userId;
		this.channelId = channelId;
		this.websiteId = websiteId;
		this.labelId = labelId;
		this.adsiteId = adsiteId;
		this.level = level;
	}

	public MediaRelationship(Long userId, Long channelId, Long websiteId,
			Long labelId, Integer level) {
		super();
		this.userId = userId;
		this.channelId = channelId;
		this.websiteId = websiteId;
		this.labelId = labelId;
		this.level = level;
	}
	public MediaRelationship(Long userId, Long channelId, Long websiteId,
			Integer level) {
		super();
		this.userId = userId;
		this.channelId = channelId;
		this.websiteId = websiteId;
		this.level = level;
	}
	public MediaRelationship(Long userId, Long channelId,  Integer level) {
		super();
		this.userId = userId;
		this.channelId = channelId;
		this.level = level;
	}

	public MediaRelationship(
		java.lang.Long id
	){
		this.id = id;
	}

	public MediaRelationship(){};
	

	public void setId(java.lang.Long value) {
		this.id = value;
	}
	
	@Id 
	@GeneratedValue(generator = "paymentableGenerator")       
	@GenericGenerator(name = "paymentableGenerator", strategy = "native")
	@Column(name = "ID", unique = true, nullable = false, insertable = true, updatable = true, length = 19)
	public java.lang.Long getId() {
		return this.id;
	}
	
	@Column(name = "USER_ID", unique = false, nullable = false, insertable = true, updatable = true, length = 19)
	public java.lang.Long getUserId() {
		return this.userId;
	}
	
	public void setUserId(java.lang.Long value) {
		this.userId = value;
	}
	
	@Column(name = "CHANNEL_ID", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getChannelId() {
		return this.channelId;
	}
	
	public void setChannelId(java.lang.Long value) {
		this.channelId = value;
	}
	
	@Column(name = "WEBSITE_ID", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getWebsiteId() {
		return this.websiteId;
	}
	
	public void setWebsiteId(java.lang.Long value) {
		this.websiteId = value;
	}
	
	@Column(name = "LABEL_ID", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getLabelId() {
		return this.labelId;
	}
	
	public void setLabelId(java.lang.Long value) {
		this.labelId = value;
	}
	
	@Column(name = "ADSITE_ID", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getAdsiteId() {
		return this.adsiteId;
	}
	
	public void setAdsiteId(java.lang.Long value) {
		this.adsiteId = value;
	}
	
	@Column(name = "LEVEL", unique = false, nullable = false, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getLevel() {
		return this.level;
	}
	
	public void setLevel(java.lang.Integer value) {
		this.level = value;
	}
	

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("Id",getId())
			.append("UserId",getUserId())
			.append("ChannelId",getChannelId())
			.append("WebsiteId",getWebsiteId())
			.append("LabelId",getLabelId())
			.append("AdsiteId",getAdsiteId())
			.append("Level",getLevel())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof MediaRelationship == false) return false;
		if(this == obj) return true;
		MediaRelationship other = (MediaRelationship)obj;
		return new EqualsBuilder()
			.append(getId(),other.getId())
			.isEquals();
	}
	@Transient
	@Override
	public String getTarget() {
		// TODO Auto-generated method stub
		return "媒体关联关系";
	}
	@Transient
	@Override
	public Long getTargetId() {
		// TODO Auto-generated method stub
		return getId();
	}
	@Transient
	@Override
	public String getTargetName() {
		// TODO Auto-generated method stub
		return "MEDIA_RELATIONSHIP" + getId();
	}
}

